<template>
  <div>
    <Card dis-hover>
      <Row class="card-title" type="flex" justify="space-between">
        <Col>商品供货信息</Col>
        <Row type="flex" justify="space-between">
          <el-button v-preventReClick type="text" size="large" :loading="saveBtnLoading" class="save-btn" @click="save">保存</el-button>
        </Row>
      </Row>
      <Row type="flex" style="padding-top: 20px;">
        <Col span="4" style="margin-right: 30px;">状态：{{this.state || '待完善'}}</Col>
        <Col span="6" style="margin-right: 30px;">管理区域：{{ topInfo.manageArea || '' }}</Col>
        <Col span="10">商品名称：{{ topInfo.productName || '' }}</Col>
      </Row>
      <div v-if="topInfo.isSaleMultiUnit=='1' || topInfo.isPurchaseMultiUnit=='1'">
        <gongyinsteel
          ref="gong"
          :topinfo="topInfo"
          :productUuid="productUuid"
          @updateLoadingState="updateLoadingState"
        />
      </div>
      <div v-else>
        <gongyin
          ref="gong"
          :topinfo="topInfo"
          :productUuid="productUuid"
          @updateLoadingState="updateLoadingState"
        />
      </div>
    </Card>
  </div>
</template>

<script>
import { ApiRequest } from '@api/basePage';
import gongyin from '@/components/commodity/addSupplyInfo/notComplateAddSupply';
import gongyinsteel from '@/components/commodity/addSupplyInfo/notComplateAddSupplySteel';

export default {
  components: {
    gongyin,
    gongyinsteel
  },
  data () {
    return {
      saveBtnLoading: false,
      isSave: true,
      topInfo: {},
      productUuid: '',
    }
  },
  mounted () {

  },
  created () {
    this.productUuid = this.$route.query.productUuid;
    this.state = this.$route.query.state;
    this.getDefaultDataNew();
  },
  methods: {
    getDefaultDataNew () {
      if (this.productUuid == null || this.productUuid == undefined) {
        return this.$Message.error('请先填写基本信息')
      };
      let data = {
        productUuid: this.productUuid,
      };
      ApiRequest('/sysback/supplyproductrel/getTopInfo', 'post', data, true).then(res => {
        this.topInfo = res.retData;
      })
    },
    save () {
      this.$refs.gong.save();
    },
    submit () {
      this.$refs.gong.submit();
    },
    updateLoadingState (state) {
      this.saveBtnLoading = state;
    }
  }
}
</script>

<style lang="less" scoped>
.save-btn {
  margin-top: 10px;
}
.card-title {
  font-size: 16px;
  color: #17233d;
  font-weight: 500;
  height: 50px;
  line-height: 50px;
  margin-top: -16px;
  border-bottom: 1px solid #e8eaec;
}
</style>
